Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat rn picker-view #1760

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Conversation

wangshunnn
Copy link
Collaborator

@wangshunnn wangshunnn commented Dec 16, 2024

No description provided.

@wangshunnn wangshunnn requested a review from hiyuki December 16, 2024 08:05
itemWidth,
textStyleFromParent,
textStyle,
hasVarDec,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个不用传递下来啊

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

理论上这玩意不需要接收样式吧

itemHeight,
itemWidth = '100%',
textStyleFromParent,
textStyle,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些style走context传递下来就可以了吧,不用props层层透传


interface ColumnProps {
children?: React.ReactNode
columnData: React.ReactNode[]
columnStyle: Record<string, any>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这又是啥

const visibleCount = 5

const _PickerViewColumn = forwardRef<HandlerRef<ScrollView & View, ColumnProps>, ColumnProps>((props: ColumnProps, ref) => {
const {
columnData,
columnIndex,
columnStyle,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥有这么多style,都是干嘛用的

)

return (
<SafeAreaView style={[{ display: 'flex', flex: 1 }]}>
<SafeAreaView style={[styles.wrapper, normalStyle]}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥需要包safeAreaView

const renderMask = () => (
<PickerMask
itemHeight={itemHeight}
maskContainerStyle={pickerMaskStyle}
Copy link
Collaborator

@hiyuki hiyuki Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overlay改为indicator

return index * itemRawH
}, [itemRawH])

const stableResetScrollPosition = useStableCallback((y: number) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个useStableCb是干嘛用的

const paddingHeight = useMemo(
() => Math.round((pickerH - itemHeight) / 2),
[pickerH, itemHeight]
)

const snapToOffsets = useMemo(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无效的useMemo

onMomentumScrollEnd({ nativeEvent: { contentOffset: { y } } })
}
})
const debounceResetScrollPosition = useDebounceCallback(stableResetScrollPosition, 10)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10ms能有效果么?感觉不用debounce,维护一个状态标记已经进行过reset就行了吧

* ✘ indicator-class
* mask-style
* mask-style
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mask-class和indicator-class需要编译支持一下,参考hover-class

const indicatorStyle = parseInlineStyle(props['indicator-style'])
const pickerMaskStyle = parseInlineStyle(props['mask-style'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要在这里单独parse,都应该走统一的getStyle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants